<template>
    <view class="safe-box">
        <NewsItem :data="info" @delete="del"></NewsItem>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                info: {},
                eventChannel: () => {}
            }
        },
        methods: {
            del(id) {
                this.$http.delete('/news', {
                    id
                }).then(() => {
                    this.eventChannel.emit('delete', id)
                    this.$nav.back()
                })
            }
        },
        onLoad(e) {
            // #ifdef APP-NVUE
              this.eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
              // #endif
              // #ifndef APP-NVUE
              this.eventChannel = this.getOpenerEventChannel();
              // #endif
            this.$http.get(`/news/${e.id}`).then(res => {
                this.info = res.data
            })
        }
    }
</script>

<style>
</style>